#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSystemTrayIcon>
#include <QProcess>
#include <QFileIconProvider>
#include "updatedbthread.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private slots:
    void on_lineEdit_returnPressed();
    void on_search_clicked();

    void onUpdatedbStart();
    void onUpdatedbFinish();
    void onUpdatedbError(const QString &msg);

    void on_tableWidget_customContextMenuRequested(const QPoint &pos);

    void onProcessStarted();
    void onProcessFinished(int exitCode);
    void onProcessReadyReadStandardOutput();

    void onTrayIconActivated(QSystemTrayIcon::ActivationReason reason);
    void updatedb();

private:
    void initSystemTrayIcon();
    void initWidgets();

private:
    Ui::MainWindow  *ui;
    UpdatedbThread  *mUpdatedbThread;
    QSystemTrayIcon *mTrayIcon;
    QProcess        *mProcess;
    QTimer          *mUpdatedbTimer;
    bool             mIsSearching = false;
    bool             mIsUpdatingDb = false;

    QFileIconProvider mFileIconrovider;
};

#endif // MAINWINDOW_H
